package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TbFactorOpSymbolSet;
import com.ruoyi.system.service.ITbFactorOpSymbolSetService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 因子算法操作符Controller
 * 
 * @author shang
 * @date 2022-03-03
 */
@RestController
@RequestMapping("/system/TbFactorOp")
public class TbFactorOpSymbolSetController extends BaseController
{
    @Autowired
    private ITbFactorOpSymbolSetService tbFactorOpSymbolSetService;

    /**
     * 查询因子算法操作符列表
     */
//    @PreAuthorize("@ss.hasPermi('system:TbFactorOp:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbFactorOpSymbolSet tbFactorOpSymbolSet)
    {
        startPage();
        List<TbFactorOpSymbolSet> list = tbFactorOpSymbolSetService.selectTbFactorOpSymbolSetList(tbFactorOpSymbolSet);
        return getDataTable(list);
    }

    /**
     * 导出因子算法操作符列表
     */
    @PreAuthorize("@ss.hasPermi('system:TbFactorOp:export')")
    @Log(title = "因子算法操作符", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbFactorOpSymbolSet tbFactorOpSymbolSet)
    {
        List<TbFactorOpSymbolSet> list = tbFactorOpSymbolSetService.selectTbFactorOpSymbolSetList(tbFactorOpSymbolSet);
        ExcelUtil<TbFactorOpSymbolSet> util = new ExcelUtil<TbFactorOpSymbolSet>(TbFactorOpSymbolSet.class);
        util.exportExcel(response, list, "因子算法操作符数据");
    }

    /**
     * 获取因子算法操作符详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:TbFactorOp:query')")
    @GetMapping(value = "/{symbolCd}")
    public AjaxResult getInfo(@PathVariable("symbolCd") Long symbolCd)
    {
        return AjaxResult.success(tbFactorOpSymbolSetService.selectTbFactorOpSymbolSetBySymbolCd(symbolCd));
    }

    /**
     * 新增因子算法操作符
     */
    @PreAuthorize("@ss.hasPermi('system:TbFactorOp:add')")
    @Log(title = "因子算法操作符", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbFactorOpSymbolSet tbFactorOpSymbolSet)
    {
        return toAjax(tbFactorOpSymbolSetService.insertTbFactorOpSymbolSet(tbFactorOpSymbolSet));
    }

    /**
     * 修改因子算法操作符
     */
    @PreAuthorize("@ss.hasPermi('system:TbFactorOp:edit')")
    @Log(title = "因子算法操作符", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbFactorOpSymbolSet tbFactorOpSymbolSet)
    {
        return toAjax(tbFactorOpSymbolSetService.updateTbFactorOpSymbolSet(tbFactorOpSymbolSet));
    }

    /**
     * 删除因子算法操作符
     */
    @PreAuthorize("@ss.hasPermi('system:TbFactorOp:remove')")
    @Log(title = "因子算法操作符", businessType = BusinessType.DELETE)
	@DeleteMapping("/{symbolCds}")
    public AjaxResult remove(@PathVariable Long[] symbolCds)
    {
        return toAjax(tbFactorOpSymbolSetService.deleteTbFactorOpSymbolSetBySymbolCds(symbolCds));
    }
}
